<!DOCTYPE html>
<html>
<head>
    <title>会员注册</title>
    <% include common/meta.ejs %>
    <% include common/public.ejs %>
    <link href="<%= global.config.path.publicPath %>/custom/officialAccount/css/officalCommon.css" rel="stylesheet">
    <link href="<%= global.config.path.publicPath %>/libs/mobiscroll-master-black/css/mobiscroll_002.css" rel="stylesheet">
    <link href="<%= global.config.path.publicPath %>/libs/mobiscroll-master-black/css/mobiscroll.css" rel="stylesheet">
    <link href="<%= global.config.path.publicPath %>/libs/mobiscroll-master-black/css/mobiscroll_003.css" rel="stylesheet">
    <link href="<%= global.config.path.publicPath %>/libs/area/css/area.css" rel="stylesheet">
    <link href="<%= global.config.path.publicPath %><%= body.stylePath %>" rel="stylesheet">

    <link rel="stylesheet" href="<%=global.config.cdn.path %>/weui/0.4.3/style/weui.min.css">
    <link rel="stylesheet" href="<%=global.config.cdn.path %>/jquery-weui/0.8.3/css/jquery-weui.min.css">
   <style>
       .content-padded {
           padding: 15px;
       }
       body{
           background-color: #FBF9FE;
       }
       button.weui-vcode-btn {
           background-color: transparent;
           border-bottom: 0 none;
           border-right: 0 none;
           border-top: 0 none;
           outline: 0 none;
       }

       .weui-vcode-btn {
           border-left: 1px solid #e5e5e5;
           color: #3cc51f;
           display: inline-block;
           font-size: 17px;
           padding: 0 0.6em 0 0.7em;
       }

       .weui-vcode-btn, .weui-vcode-img {
           margin-left: 5px;
           vertical-align: middle;
       }

       .weui_cells {
           margin-top: 10px;
       }
   </style>

</head>
<body ontouchstart>
<div id="register" class="content-padded">

    <form id="registrationForm" class="clearfix">
        <input type="hidden" name="brandId" value="<%=body.brandId%>">
        <input type="hidden" name="openId">
        <input type="hidden" name="publicId">
        <input type="hidden" name="gId">
        <input type="hidden" name="vipAddress" value="">

        <div class="weui_cells weui_cells_form">
            <div class="weui_cell" style="border: 1px solid #d7d7d7; border-radius:3px;box-shadow: 0 0 0 1px #d7d7d7;">
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input acc-input" type="text" placeholder="请输入您的真实姓名" name="vipName">
                </div>
            </div>
        </div>

        <div class="weui_cells weui_cells_form">
            <div class="weui_cell" style="border: 1px solid #d7d7d7; border-radius:3px;box-shadow: 0 0 0 1px #d7d7d7;">
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input" id="mobileInput" type="text" placeholder="请输入您的手机号码" name="vipMobile">
                </div>
            </div>
        </div>

        <div class="weui_cells weui_cells_form">
            <div class="weui_cell" style="border: 1px solid #d7d7d7; border-radius:3px;box-shadow: 0 0 0 1px #d7d7d7;">
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input mbsc-comp" type="text" id="date-input" placeholder="您的生日" name="vipBirthday" readonly="">
                </div>
            </div>
        </div>

        <!--<div class="weui_cells weui_cells_form" hidden>-->
            <!--<div class="weui_cell" style="border: 1px solid #d7d7d7; border-radius:3px;box-shadow: 0 0 0 1px #d7d7d7;">-->
                <!--<div class="weui_cell_bd weui_cell_primary">-->
                    <!--<input class="weui_input" type="text" id="address-input" placeholder="您的地址" name="vipAddress" readonly="">-->
                <!--</div>-->
            <!--</div>-->
        <!--</div>-->

        <%
        var showFlag = false;
        if(global.config.introCardCodeGId){
            for(var i = 0; i < global.config.introCardCodeGId.length; i++){
                if(body.gId === global.config.introCardCodeGId[i]){
                    showFlag = true;
                    break;
                }
            }
        }
        %>
        <%if(showFlag){%>
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell" style="border: 1px solid #d7d7d7; border-radius:3px;box-shadow: 0 0 0 1px #d7d7d7;">
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input" id="introCardCode" type="text" placeholder="请输入推荐人卡号" name="introCardCode">
                </div>
            </div>
        </div>
        <%}%>

        <!--<div class="weui_cells weui_cells_form">-->

            <!--<div class="browser" style="border: 1px solid #d7d7d7; border-radius:3px;box-shadow: 0 0 0 1px #d7d7d7;">-->
                <!--&lt;!&ndash;选择地区&ndash;&gt;-->
                <!--<section class="express-area">-->
                    <!--<a id="expressArea" href="javascript:void(0)">-->
                        <!--<dl>-->
                            <!--<dt>选择地区：</dt>-->
                            <!--<dd>省 > 市 > 区/县</dd>-->
                        <!--</dl>-->
                    <!--</a>-->
                <!--</section>-->
                <!--&lt;!&ndash;选择地区弹层&ndash;&gt;-->
                <!--<section id="areaLayer" class="express-area-box">-->
                    <!--<header>-->
                        <!--<h3>选择地区</h3>-->
                        <!--<a id="backUp" class="back" href="javascript:void(0)" title="返回"  style="background-image: url('<%=global.config.path.publicPath%>/images/back.png')"></a>-->
                        <!--<a id="closeArea" class="close" href="javascript:void(0)" title="关闭"  style="background-image: url('<%=global.config.path.publicPath%>/images/close-area.png')"></a>-->
                    <!--</header>-->
                    <!--<article id="areaBox">-->
                        <!--<ul id="areaList" class="area-list"></ul>-->
                    <!--</article>-->
                <!--</section>-->
                <!--&lt;!&ndash;遮罩层&ndash;&gt;-->
                <!--<div id="areaMask" class="mask"></div>-->
            <!--</div>-->
        <!--</div>-->

        <div class="weui_cells weui_cells_form">
            <input  class="weui_btn weui_btn_default"  id="submitBtn"  value="申请会员卡" onclick="return check(this.form)">
        </div>
    </form>
</div>

<% include common/footer.ejs %>
<script src="<%=global.config.cdn.path %>/jquery/1.11.0/jquery.min.js"></script>
<script src="<%=global.config.cdn.path %>/jquery-weui/0.8.3/js/jquery-weui.min.js"></script>
<script src="<%=global.config.cdn.path %>/jquery-weui/0.8.3/js/swiper.min.js"></script>
<script src="<%=global.config.cdn.path %>/jquery-weui/0.8.3/js/city-picker.min.js"></script>

<script type="text/javascript" src="<%=global.config.path.publicPath%>/libs/mobiscroll-master-black/js/mobiscroll_002.js"></script>
<script type="text/javascript" src="<%=global.config.path.publicPath%>/libs/mobiscroll-master-black/js/mobiscroll_004.js"></script>
<script type="text/javascript" src="<%=global.config.path.publicPath%>/libs/mobiscroll-master-black/js/mobiscroll.js"></script>
<script type="text/javascript" src="<%=global.config.path.publicPath%>/libs/mobiscroll-master-black/js/mobiscroll_003.js"></script>
<script type="text/javascript" src="<%=global.config.path.publicPath%>/libs/mobiscroll-master-black/js/mobiscroll_005.js"></script>
<script type="text/javascript" src="<%=global.config.path.publicPath%>/libs/area/js/jquery.area.js"></script>

<script>
    var _hmt = _hmt || [];
    (function () {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?d13328b5db725a57a4babbcacdd4c38d";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
</script>
<script>
    function check(form) {
        if (form['vipName'].value == '') {
            alert("请输入您的姓名!");
            form['vipName'].focus();
            return false;
        }
        if (form.vipMobile.value == '') {
            alert("请输入您的手机号码!");
            form.vipMobile.focus();
            return false;
        }
        if(!(/^1\d{10}$/.test(form.vipMobile.value) || (/^(5|6|8|9)\d{7}$/).test(form.vipMobile.value))){
            alert("请输入正确的手机号码！");
            form.vipMobile.focus();
            return false;
        }
        if (form.vipBirthday.value == '') {
            alert("请输入您的生日!");
            form.vipBirthday.focus();
            return false;
        }
//        if (form.vipAddress.value == '') {
//            alert("请选择您的地址!");
//            return false;
//        }
        $.ajax({
            type: "POST",
            url:'<%=global.config.path.contextPath%>/work/register',
            data:$('#registrationForm').serialize(),
            async: false,
            error: function(request) {
                alert('网络有些差，请退出再试一次吧:)')
            },
            success: function(data) {
                console.log(data);
                if(data.err){
                    alert(data.err);
                }else if(data.resolve){
                    alert(data.resolve)
                }else {
                    window.location.href="<%=global.config.path.contextPath%>/view/index?openId="+contextData.data.openid+"&gId="+contextData.data.gId+"&publicId="+contextData.data.publicId+"&brand="+contextData.data.brand;
                    $('#submitBtn').attr('disabled','disabled')
                }
            }
        })
    }

    $(function () {
        $("input[name='openId']").val(contextData.data.openid);
        $("input[name='publicId']").val(contextData.data.publicId);
        $("input[name='gId']").val(contextData.data.gId);


        $('#date-input').mobiscroll().date({
            theme: 'android-ics light', //皮肤样式            preset: 'date',
            showNow: false,
            dateFormat: 'yyyy-mm-dd',
            timeFormat: 'HH:ii',
            mode: 'scroller',
            lang: 'zh',
            startYear: '1910',
            endYear: '2018',

        });
    });


</script>
</body>
</html>
